//
//  TKPNavigationController.m
//  Thinkape-iOS
//
//  Created by admin on 16/6/12.
//  Copyright © 2016年 TIXA. All rights reserved.
//

#import "TKPNavigationController.h"

@implementation TKPNavigationController
#pragma mark
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    for (UIViewController *vc in self.viewControllers) {
        NSString *className = NSStringFromClass([vc class]);
        if ([className isEqualToString:@"StatementViewController"]) {
            return YES;
        }
    }
    return NO;
}

#pragma mark - Worked for iOS >= 6.0
- (BOOL)shouldAutorotate
{

    NSLog(@"%@",self.viewControllers);
    for (UIViewController *vc in self.viewControllers) {
        NSString *className = NSStringFromClass([vc class]);
        if ([className isEqualToString:@"StatementViewController"]) {
            return YES;
        }
    }
    return NO;

}
//
//- (NSUInteger)supportedInterfaceOrientations {
//    return UIInterfaceOrientationMaskAllButUpsideDown;
//}

- (UIInterfaceOrientationMask)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED
{
    
    for (UIViewController *vc in self.viewControllers) {
        NSString *className = NSStringFromClass([vc class]);
        if ([className isEqualToString:@"StatementViewController"]) {
            return UIInterfaceOrientationMaskAllButUpsideDown;
        }
        
    }
    
    return UIInterfaceOrientationMaskPortrait;
}

//必须的方法：这个实现了为了是返回的时候主界面是竖屏的
-(NSUInteger)supportedInterfaceOrientations {
    return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}

//
//- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
////    return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
//    return YES;
//}


@end
